<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateCompany extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('company',['comment'=>'公司','collation'=>'utf8mb4_general_ci']);
        $table->addColumn('name','string',['limit'=>50,'comment'=>'公司名称'])
            ->addColumn('desc','string',['limit'=>100,'default'=>'','comment'=>'公司描述'])
            ->addColumn('employee_num','integer',['limit'=>10,'comment'=>'员工数量'])
            ->addColumn('charge_person','string',['limit'=>30,'comment'=>'负责人姓名'])
            ->addColumn('charge_person_phone','string',['limit'=>11,'comment'=>'负责人手机号'])
            ->addColumn('status','boolean',['limit'=>1,'default'=>1,'comment'=>'公司状态 1正常 2禁用'])
            ->addColumn('create_time','datetime',['comment'=>'创建时间'])
            ->addColumn('update_time','datetime',['comment'=>'更新时间'])
            ->create();

    }
}
